Metropolis-Hastings Algorithm

What it is

Metropolis-Hastings Algorithm is a general framework which includes as special cases the very first and simpler MCMC Markov chain Monte Carlo Algorithm.

How it works

Consider an arbitrary posterior p(z) and its transition matrix Q(zz), it cannot always satisfy the detailed balance. If we want to achieve the detailed balance, we should add an acceptance ration α, to make the equation correct:

p(z)Q(zz)α(z,z)=p(z)Q(zz)α(z,z)

in which one can derive α:

α(z,z)=min(1,p(z)Q(z|z)p(z),Q(z|z))

This is how Metropolis Hastings work:

  1. sample zQ(z|zi1)
  2. sample uU(0,1)
  3. α=min(1,p(z)Q(z|z)p(z),Q(z|z))
  4. decision:
    • if uα, accept zi=z
    • else, reject z and accept zi=zi1

Gibbs Sampling